// database.module.ts
import { Module } from '@nestjs/common';
import { TypeOrmModule, TypeOrmModuleOptions } from '@nestjs/typeorm';
import { Student } from './student/entities/student.entity';

@Module({
  imports: [
    // database.module.ts
    TypeOrmModule.forRootAsync({
      useFactory: (): TypeOrmModuleOptions => ({
        type: 'postgres',
        host: 'localhost',
        port: 15432, // Docker映射端口
        username: 'gaussdb', // 默认超级用户
        password: 'Hgy040304!', // 你的启动密码
        database: 'student_db',
        entities: [__dirname + '/**/entities/*.entity{.ts,.js}'], // 推荐直接引用实体类
        synchronize: true,
        logging: true,
        // extra: { // 添加SSL配置
        //   ssl: {
        //     rejectUnauthorized: false
        //   }
        // }
      })
    })
  ],
})
export class DatabaseModule {}
